<template>
  <div class="app-container">
    <el-form :model="queryParams" ref="queryForm" size="small" :inline="true" v-show="showSearch" label-width="68px">
      <el-form-item label="单据编号" prop="billnumber">
        <el-input
          v-model="queryParams.billnumber"
          placeholder="请输入单据编号"
          clearable
          @keyup.enter.native="handleQuery"
        />
      </el-form-item>
      <el-form-item label="业务日期" prop="bizdate">
        <el-date-picker
          v-model="daterangeBizdate"
          style="width: 240px"
          value-format="yyyy-MM-dd"
          type="daterange"
          range-separator="-"
          start-placeholder="开始日期"
          end-placeholder="结束日期"
        ></el-date-picker>
      </el-form-item>
      <el-form-item label="库存组织编码" prop="storageorgnumber">
        <el-input
          v-model="queryParams.storageorgnumber"
          placeholder="请输入库存组织编码"
          clearable
          @keyup.enter.native="handleQuery"
        />
      </el-form-item>
      <el-form-item label="库存组织名称" prop="storageorgname">
        <el-input
          v-model="queryParams.storageorgname"
          placeholder="请输入库存组织名称"
          clearable
          @keyup.enter.native="handleQuery"
        />
      </el-form-item>
      <el-form-item label="业务类型编码" prop="biztypenumber">
        <el-input
          v-model="queryParams.biztypenumber"
          placeholder="请输入业务类型编码"
          clearable
          @keyup.enter.native="handleQuery"
        />
      </el-form-item>
      <el-form-item label="业务类型名称" prop="biztypename">
        <el-input
          v-model="queryParams.biztypename"
          placeholder="请输入业务类型名称"
          clearable
          @keyup.enter.native="handleQuery"
        />
      </el-form-item>
      <el-form-item label="事务类型编码" prop="transactiontypenumber">
        <el-input
          v-model="queryParams.transactiontypenumber"
          placeholder="请输入事务类型编码"
          clearable
          @keyup.enter.native="handleQuery"
        />
      </el-form-item>
      <el-form-item label="事务类型名称" prop="transactiontypename">
        <el-input
          v-model="queryParams.transactiontypename"
          placeholder="请输入事务类型名称"
          clearable
          @keyup.enter.native="handleQuery"
        />
      </el-form-item>
<!--      <el-form-item label="供应商编码" prop="suppliernumber">-->
<!--        <el-input-->
<!--          v-model="queryParams.suppliernumber"-->
<!--          placeholder="请输入供应商编码"-->
<!--          clearable-->
<!--          @keyup.enter.native="handleQuery"-->
<!--        />-->
<!--      </el-form-item>-->
<!--      <el-form-item label="供应商名称" prop="suppliername">-->
<!--        <el-input-->
<!--          v-model="queryParams.suppliername"-->
<!--          placeholder="请输入供应商名称"-->
<!--          clearable-->
<!--          @keyup.enter.native="handleQuery"-->
<!--        />-->
<!--      </el-form-item>-->
<!--      <el-form-item label="记账公司编码" prop="accountcompanynumber">-->
<!--        <el-input-->
<!--          v-model="queryParams.accountcompanynumber"-->
<!--          placeholder="请输入记账公司编码"-->
<!--          clearable-->
<!--          @keyup.enter.native="handleQuery"-->
<!--        />-->
<!--      </el-form-item>-->
<!--      <el-form-item label="记账公司名称" prop="accountcompanyname">-->
<!--        <el-input-->
<!--          v-model="queryParams.accountcompanyname"-->
<!--          placeholder="请输入记账公司名称"-->
<!--          clearable-->
<!--          @keyup.enter.native="handleQuery"-->
<!--        />-->
<!--      </el-form-item>-->
      <el-form-item label="成本中心编码" prop="costcenternumber">
        <el-input
          v-model="queryParams.costcenternumber"
          placeholder="请输入成本中心编码"
          clearable
          @keyup.enter.native="handleQuery"
        />
      </el-form-item>
      <el-form-item label="成本中心名称" prop="costcentername">
        <el-input
          v-model="queryParams.costcentername"
          placeholder="请输入成本中心名称"
          clearable
          @keyup.enter.native="handleQuery"
        />
      </el-form-item>
<!--      <el-form-item label="币别" prop="currency">-->
<!--        <el-input-->
<!--          v-model="queryParams.currency"-->
<!--          placeholder="请输入币别"-->
<!--          clearable-->
<!--          @keyup.enter.native="handleQuery"-->
<!--        />-->
<!--      </el-form-item>-->
<!--      <el-form-item label="汇率" prop="exchangerate">-->
<!--        <el-input-->
<!--          v-model="queryParams.exchangerate"-->
<!--          placeholder="请输入汇率"-->
<!--          clearable-->
<!--          @keyup.enter.native="handleQuery"-->
<!--        />-->
<!--      </el-form-item>-->
<!--      <el-form-item label="参考信息" prop="description">-->
<!--        <el-input-->
<!--          v-model="queryParams.description"-->
<!--          placeholder="请输入参考信息"-->
<!--          clearable-->
<!--          @keyup.enter.native="handleQuery"-->
<!--        />-->
<!--      </el-form-item>-->
      <el-form-item label="已传EAS" prop="istrans">
        <el-select v-model="queryParams.istrans" placeholder="请选择已传EAS" clearable>
          <el-option
            style="width: 215px"
            v-for="dict in dict.type.yes_no"
            :key="dict.value"
            :label="dict.label"
            :value="dict.value"
          />
        </el-select>
      </el-form-item>
      <el-form-item label="来源系统" prop="srcsys">
        <el-input
          v-model="queryParams.srcsys"
          placeholder="请输入来源系统"
          clearable
          @keyup.enter.native="handleQuery"
        />
      </el-form-item>
<!--      <el-form-item label="传送日期" prop="transtime">-->
<!--        <el-date-picker clearable-->
<!--          v-model="queryParams.transtime"-->
<!--          type="date"-->
<!--          value-format="yyyy-MM-dd"-->
<!--          placeholder="请选择传送日期">-->
<!--        </el-date-picker>-->
<!--      </el-form-item>-->
<!--      <el-form-item label="失败原因" prop="reason">-->
<!--        <el-input-->
<!--          v-model="queryParams.reason"-->
<!--          placeholder="请输入失败原因"-->
<!--          clearable-->
<!--          @keyup.enter.native="handleQuery"-->
<!--        />-->
<!--      </el-form-item>-->
<!--      <el-form-item label="创建时间" prop="createtime">-->
<!--        <el-input-->
<!--          v-model="queryParams.createtime"-->
<!--          placeholder="请输入创建时间"-->
<!--          clearable-->
<!--          @keyup.enter.native="handleQuery"-->
<!--        />-->
<!--      </el-form-item>-->
      <el-form-item>
        <el-button type="primary" icon="el-icon-search" size="mini" @click="handleQuery">搜索</el-button>
        <el-button icon="el-icon-refresh" size="mini" @click="resetQuery">重置</el-button>
      </el-form-item>
    </el-form>

    <el-row :gutter="10" class="mb8">
      <el-col :span="1.5">
        <el-button
          type="primary"
          plain
          icon="el-icon-plus"
          size="mini"
          @click="handleAdd"
          v-hasPermi="['settlementCenter/basebill:sumpurinwarehsbill:add']"
        >新增</el-button>
      </el-col>
      <el-col :span="1.5">
        <el-button
          type="success"
          plain
          icon="el-icon-edit"
          size="mini"
          :disabled="single"
          @click="handleUpdate"
          v-hasPermi="['settlementCenter/basebill:sumpurinwarehsbill:edit']"
        >修改</el-button>
      </el-col>
      <el-col :span="1.5">
        <el-button
          type="danger"
          plain
          icon="el-icon-delete"
          size="mini"
          :disabled="multiple"
          @click="handleDelete"
          v-hasPermi="['settlementCenter/basebill:sumpurinwarehsbill:remove']"
        >删除</el-button>
      </el-col>
      <el-col :span="1.5">
        <el-button
          type="warning"
          plain
          icon="el-icon-download"
          size="mini"
          @click="handleExport"
          v-hasPermi="['settlementCenter/basebill:sumpurinwarehsbill:export']"
        >导出</el-button>
      </el-col>
      <right-toolbar :showSearch.sync="showSearch" @queryTable="getList"></right-toolbar>
    </el-row>

    <el-table v-loading="loading" :data="sumpurinwarehsbillList"
              height="600px"
              ref="serveTable" @row-click="rowClick" :row-class-name="rowBillHeadIndex" @selection-change="handleSelectionChange">
      <el-table-column type="selection" width="55" align="center" />
<!--      <el-table-column label="id" align="center" prop="id" />-->
      <el-table-column label="序号" align="center" prop="index" />
      <el-table-column label="单据编号" align="center" prop="billnumber" />
      <el-table-column label="业务日期" align="center" prop="bizdate" width="180">
        <template slot-scope="scope">
          <span>{{ parseTime(scope.row.bizdate, '{y}-{m}-{d}') }}</span>
        </template>
      </el-table-column>
      <el-table-column label="来源系统" align="center" prop="srcsys" />

      <el-table-column label="库存组织编码" align="center" prop="storageorgnumber" />
      <el-table-column label="库存组织名称" align="center" prop="storageorgname" />
      <el-table-column label="业务类型编码" align="center" prop="biztypenumber" />
      <el-table-column label="业务类型名称" align="center" prop="biztypename" />
      <el-table-column label="事务类型编码" align="center" prop="transactiontypenumber" />
      <el-table-column label="事务类型名称" align="center" prop="transactiontypename" />
      <el-table-column label="供应商编码" align="center" prop="suppliernumber" />
      <el-table-column label="供应商名称" align="center" prop="suppliername" />
      <el-table-column label="记账公司编码" align="center" prop="accountcompanynumber" />
      <el-table-column label="记账公司名称" align="center" prop="accountcompanyname" />
      <el-table-column label="成本中心编码" align="center" prop="costcenternumber" />
      <el-table-column label="成本中心名称" align="center" prop="costcentername" />
      <el-table-column label="币别" align="center" prop="currency" />
      <el-table-column label="汇率" align="center" prop="exchangerate" />
      <el-table-column label="参考信息" align="center" prop="description" />
      <el-table-column label="已传EAS" align="center" prop="istrans">
        <template slot-scope="scope">
          <dict-tag :options="dict.type.yes_no" :value="scope.row.istrans"/>
        </template>
      </el-table-column>
      <el-table-column label="传送日期" align="center" prop="transtime" width="180">
        <template slot-scope="scope">
          <span>{{ parseTime(scope.row.transtime, '{y}-{m}-{d}') }}</span>
        </template>
      </el-table-column>
      <el-table-column label="失败原因" align="center" prop="reason" :show-overflow-tooltip="true"/>
      <el-table-column label="创建时间" align="center" prop="createtime" >
        <template slot-scope="scope">
          <span>{{ parseTime(scope.row.createtime, '{y}-{m}-{d}') }}</span>
        </template>
      </el-table-column>
      <el-table-column label="操作" align="center" class-name="small-padding fixed-width">
        <template slot-scope="scope">
          <el-button
            size="mini"
            type="text"
            icon="el-icon-edit"
            @click.native.stop="handleUpdate(scope.row)"
            v-hasPermi="['settlementCenter/basebill:sumpurinwarehsbill:edit']"
          >修改</el-button>
          <el-button
            size="mini"
            type="text"
            icon="el-icon-delete"
            @click.native.stop="handleDelete(scope.row)"
            v-hasPermi="['settlementCenter/basebill:sumpurinwarehsbill:remove']"
          >删除</el-button>
        </template>
      </el-table-column>
    </el-table>

    <pagination
      v-show="total>0"
      :total="total"
      :page.sync="queryParams.pageNum"
      :limit.sync="queryParams.pageSize"
      @pagination="getList"
    />

    <!-- 添加或修改汇总采购入库单对话框 -->
    <el-dialog :title="title" :visible.sync="open" width="1500px" append-to-body>
      <el-form ref="form" :model="form" :rules="rules" label-width="100px">
        <el-row>
          <el-col :span="6">
            <el-form-item label="单据编号" prop="billnumber">
              <el-input v-model="form.billnumber" placeholder="请输入单据编号" />
            </el-form-item>
          </el-col>
          <el-col :span="6">
            <el-form-item label="业务日期" prop="bizdate">
              <el-date-picker clearable
                              v-model="form.bizdate"
                              type="date"
                              value-format="yyyy-MM-dd"
                              placeholder="请选择业务日期">
              </el-date-picker>
            </el-form-item>
          </el-col>
          <el-col :span="6">
            <el-form-item label="库存组织编码" prop="storageorgnumber">
              <el-input v-model="form.storageorgnumber" placeholder="请输入库存组织编码" />
            </el-form-item>
          </el-col>
          <el-col :span="6">
            <el-form-item label="库存组织名称" prop="storageorgname">
              <el-input v-model="form.storageorgname" placeholder="请输入库存组织名称" />
            </el-form-item>
          </el-col>
          <el-col :span="6">
            <el-form-item label="业务类型编码" prop="biztypenumber">
              <el-input v-model="form.biztypenumber" placeholder="请输入业务类型编码" />
            </el-form-item>
          </el-col>
          <el-col :span="6">
            <el-form-item label="业务类型名称" prop="biztypename">
              <el-input v-model="form.biztypename" placeholder="请输入业务类型名称" />
            </el-form-item>
          </el-col>
          <el-col :span="6">
            <el-form-item label="事务类型编码" prop="transactiontypenumber">
              <el-input v-model="form.transactiontypenumber" placeholder="请输入事务类型编码" />
            </el-form-item>
          </el-col>
          <el-col :span="6">
            <el-form-item label="事务类型名称" prop="transactiontypename">
              <el-input v-model="form.transactiontypename" placeholder="请输入事务类型名称" />
            </el-form-item>
          </el-col>
          <el-col :span="6">
            <el-form-item label="供应商编码" prop="suppliernumber">
              <el-input v-model="form.suppliernumber" placeholder="请输入供应商编码" />
            </el-form-item>
          </el-col>
          <el-col :span="6">
            <el-form-item label="供应商名称" prop="suppliername">
              <el-input v-model="form.suppliername" placeholder="请输入供应商名称" />
            </el-form-item>
          </el-col>
          <el-col :span="6">
            <el-form-item label="记账公司编码" prop="accountcompanynumber">
              <el-input v-model="form.accountcompanynumber" placeholder="请输入记账公司编码" />
            </el-form-item>
          </el-col>
          <el-col :span="6">
            <el-form-item label="记账公司名称" prop="accountcompanyname">
              <el-input v-model="form.accountcompanyname" placeholder="请输入记账公司名称" />
            </el-form-item>
          </el-col>
          <el-col :span="6">
            <el-form-item label="成本中心编码" prop="costcenternumber">
              <el-input v-model="form.costcenternumber" placeholder="请输入成本中心编码" />
            </el-form-item>
          </el-col>
          <el-col :span="6">
            <el-form-item label="成本中心名称" prop="costcentername">
              <el-input v-model="form.costcentername" placeholder="请输入成本中心名称" />
            </el-form-item>
          </el-col>
          <el-col :span="6">
            <el-form-item label="币别" prop="currency">
              <el-input v-model="form.currency" placeholder="请输入币别" />
            </el-form-item>
          </el-col>
          <el-col :span="6">
            <el-form-item label="汇率" prop="exchangerate">
              <el-input v-model="form.exchangerate" placeholder="请输入汇率" />
            </el-form-item>
          </el-col>
          <el-col :span="6">
            <el-form-item label="参考信息" prop="description">
              <el-input v-model="form.description" placeholder="请输入参考信息" />
            </el-form-item>
          </el-col>
          <el-col :span="6">
            <el-form-item label="已传EAS" prop="istrans">
              <el-select v-model="form.istrans" placeholder="请选择已传EAS">
                <el-option
                  v-for="dict in dict.type.yes_no"
                  :key="dict.value"
                  :label="dict.label"
                  :value="dict.value"
                ></el-option>
              </el-select>
            </el-form-item>
          </el-col>
          <el-col :span="6">
            <el-form-item label="来源系统" prop="srcsys">
              <el-input v-model="form.srcsys" />
            </el-form-item>
          </el-col>
          <el-col :span="6">
            <el-form-item label="传送日期" prop="transtime">
              <el-date-picker clearable
                              v-model="form.transtime"
                              type="date"
                              value-format="yyyy-MM-dd"
                              placeholder="请选择传送日期">
              </el-date-picker>
            </el-form-item>
          </el-col>
          <el-col :span="24">
            <el-form-item label="失败原因" prop="reason">
              <el-input v-model="form.reason" type="textarea" autosize/>
            </el-form-item>
          </el-col>
        </el-row>

        <el-divider content-position="center">汇总采购入库单明细信息</el-divider>
        <el-row :gutter="10" class="mb8">
          <el-col :span="1.5">
            <el-button type="primary" icon="el-icon-plus" size="mini" @click="handleAddOmsSumpurinwarehsbillentry">添加</el-button>
          </el-col>
          <el-col :span="1.5">
            <el-button type="danger" icon="el-icon-delete" size="mini" @click="handleDeleteOmsSumpurinwarehsbillentry">删除</el-button>
          </el-col>
        </el-row>
        <el-table :data="omsSumpurinwarehsbillentryList" :row-class-name="rowOmsSumpurinwarehsbillentryIndex" @selection-change="handleOmsSumpurinwarehsbillentrySelectionChange" ref="omsSumpurinwarehsbillentry">
          <el-table-column type="selection" width="50" align="center" />
          <el-table-column label="序号" align="center" prop="index" width="50"/>
          <el-table-column label="仓库编码" prop="warehousenumber" width="150">
            <template slot-scope="scope">
              <el-input v-model="scope.row.warehousenumber" placeholder="请输入仓库编码" />
            </template>
          </el-table-column>
          <el-table-column label="仓库名称" prop="warehousename" width="150">
            <template slot-scope="scope">
              <el-input v-model="scope.row.warehousename" placeholder="请输入仓库名称" />
            </template>
          </el-table-column>
          <el-table-column label="物料编码" prop="materialnumber" width="150">
            <template slot-scope="scope">
              <el-input v-model="scope.row.materialnumber" placeholder="请输入物料编码" />
            </template>
          </el-table-column>
          <el-table-column label="物料名称" prop="materialname" width="150">
            <template slot-scope="scope">
              <el-input v-model="scope.row.materialname" placeholder="请输入物料名称" />
            </template>
          </el-table-column>
          <el-table-column label="计量单位" prop="unitnumber" width="150">
            <template slot-scope="scope">
              <el-input v-model="scope.row.unitnumber" placeholder="请输入计量单位" />
            </template>
          </el-table-column>
          <el-table-column label="基本计量单位" prop="baseunitnumber" width="150">
            <template slot-scope="scope">
              <el-input v-model="scope.row.baseunitnumber" placeholder="请输入基本计量单位" />
            </template>
          </el-table-column>
          <el-table-column label="数量" prop="qty" width="150">
            <template slot-scope="scope">
              <el-input v-model="scope.row.qty" placeholder="请输入数量" />
            </template>
          </el-table-column>
          <el-table-column label="基本单位数量" prop="baseqty" width="150">
            <template slot-scope="scope">
              <el-input v-model="scope.row.baseqty" placeholder="请输入基本单位数量" />
            </template>
          </el-table-column>
          <el-table-column label="单价" prop="price" width="150">
            <template slot-scope="scope">
              <el-input v-model="scope.row.price" placeholder="请输入单价" />
            </template>
          </el-table-column>
          <el-table-column label="税率" prop="taxrate" width="150">
            <template slot-scope="scope">
              <el-input v-model="scope.row.taxrate" placeholder="请输入税率" />
            </template>
          </el-table-column>
          <el-table-column label="含税单价" prop="taxprice" width="150">
            <template slot-scope="scope">
              <el-input v-model="scope.row.taxprice" placeholder="请输入含税单价" />
            </template>
          </el-table-column>
          <el-table-column label="金额" prop="amount" width="150">
            <template slot-scope="scope">
              <el-input v-model="scope.row.amount" placeholder="请输入金额" />
            </template>
          </el-table-column>
          <el-table-column label="税额" prop="tax" width="150">
            <template slot-scope="scope">
              <el-input v-model="scope.row.tax" placeholder="请输入税额" />
            </template>
          </el-table-column>
          <el-table-column label="价税合计" prop="taxamount" width="150">
            <template slot-scope="scope">
              <el-input v-model="scope.row.taxamount" placeholder="请输入价税合计" />
            </template>
          </el-table-column>
          <el-table-column label="是否赠品" prop="ispresent" width="150">
            <template slot-scope="scope">
              <el-select v-model="scope.row.ispresent" placeholder="请选择是否赠品">
                <el-option
                  v-for="dict in dict.type.yes_no"
                  :key="dict.value"
                  :label="dict.label"
                  :value="dict.value"
                ></el-option>
              </el-select>
            </template>
          </el-table-column>
          <el-table-column label="备注" prop="remark" width="150">
            <template slot-scope="scope">
              <el-input v-model="scope.row.remark" placeholder="请输入备注" />
            </template>
          </el-table-column>
        </el-table>
      </el-form>
      <div slot="footer" class="dialog-footer">
        <el-button type="primary" @click="submitForm">确 定</el-button>
        <el-button @click="cancel">取 消</el-button>
      </div>
    </el-dialog>
  </div>
</template>

<script>
import { listSumpurinwarehsbill, getSumpurinwarehsbill, delSumpurinwarehsbill, addSumpurinwarehsbill, updateSumpurinwarehsbill } from "@/api/settlementCenter/basebill/sumpurinwarehsbill";

export default {
  name: "Sumpurinwarehsbill",
  dicts: ['yes_no'],
  data() {
    return {
      // 遮罩层
      loading: true,
      // 选中数组
      ids: [],
      // 子表选中数据
      checkedOmsSumpurinwarehsbillentry: [],
      // 非单个禁用
      single: true,
      // 非多个禁用
      multiple: true,
      // 显示搜索条件
      showSearch: true,
      // 总条数
      total: 0,
      // 汇总采购入库单表格数据
      sumpurinwarehsbillList: [],
      // 汇总采购入库单明细表格数据
      omsSumpurinwarehsbillentryList: [],
      // 弹出层标题
      title: "",
      // 是否显示弹出层
      open: false,
      //时间范围
      daterangeBizdate: [],
      // 查询参数
      queryParams: {
        pageNum: 1,
        pageSize: 10,
        billnumber: null,
        bizdate: null,
        storageorgnumber: null,
        storageorgname: null,
        biztypenumber: null,
        biztypename: null,
        transactiontypenumber: null,
        transactiontypename: null,
        suppliernumber: null,
        suppliername: null,
        accountcompanynumber: null,
        accountcompanyname: null,
        costcenternumber: null,
        costcentername: null,
        currency: null,
        exchangerate: null,
        description: null,
        istrans: null,
        transtime: null,
        reason: null,
        createtime: null,
        srcsys: null,
      },
      // 表单参数
      form: {},
      // 表单校验
      rules: {
      }
    };
  },
  created() {
    this.getList();
  },
  methods: {
    /** 查询汇总采购入库单列表 */
    getList() {
      this.loading = true;
      this.queryParams.params = {};
      if (null != this.daterangeBizdate && '' != this.daterangeBizdate) {
        this.queryParams.params["beginBizdate"] = this.daterangeBizdate[0];
        this.queryParams.params["endBizdate"] = this.daterangeBizdate[1];
      }
      listSumpurinwarehsbill(this.queryParams).then(response => {
        this.sumpurinwarehsbillList = response.rows;
        this.total = response.total;
        this.loading = false;
      });
    },
    // 取消按钮
    cancel() {
      this.open = false;
      this.reset();
    },
    // 表单重置
    reset() {
      this.form = {
        id: null,
        billnumber: null,
        bizdate: null,
        storageorgnumber: null,
        storageorgname: null,
        biztypenumber: null,
        biztypename: null,
        transactiontypenumber: null,
        transactiontypename: null,
        suppliernumber: null,
        suppliername: null,
        accountcompanynumber: null,
        accountcompanyname: null,
        costcenternumber: null,
        costcentername: null,
        currency: null,
        exchangerate: null,
        description: null,
        istrans: null,
        transtime: null,
        reason: null,
        createtime: null,
        srcsys: null,
      };
      this.omsSumpurinwarehsbillentryList = [];
      this.resetForm("form");
    },
    /** 搜索按钮操作 */
    handleQuery() {
      this.queryParams.pageNum = 1;
      this.getList();
    },
    /** 重置按钮操作 */
    resetQuery() {
      this.resetForm("queryForm");
      this.daterangeBizdate = [];
      this.handleQuery();
    },
    //监听row-click事件，实现选中
    rowClick(row, column, event) {
      let refsElTable = this.$refs.serveTable; // 获取表格对象
      refsElTable.toggleRowSelection(row);  //如过重复选中，则取消选中
    },
    // 多选框选中数据
    handleSelectionChange(selection) {
      this.ids = selection.map(item => item.id)
      this.single = selection.length!==1
      this.multiple = !selection.length
    },
    /** 新增按钮操作 */
    handleAdd() {
      this.reset();
      this.open = true;
      this.title = "添加汇总采购入库单";
    },
    /** 修改按钮操作 */
    handleUpdate(row) {
      this.reset();
      const id = row.id || this.ids
      getSumpurinwarehsbill(id).then(response => {
        this.form = response.data;
        this.omsSumpurinwarehsbillentryList = response.data.omsSumpurinwarehsbillentryList;
        this.open = true;
        this.title = "修改汇总采购入库单";
      });
    },
    /** 提交按钮 */
    submitForm() {
      this.$refs["form"].validate(valid => {
        if (valid) {
          this.form.omsSumpurinwarehsbillentryList = this.omsSumpurinwarehsbillentryList;
          if (this.form.id != null) {
            updateSumpurinwarehsbill(this.form).then(response => {
              this.$modal.msgSuccess("修改成功");
              this.open = false;
              this.getList();
            });
          } else {
            addSumpurinwarehsbill(this.form).then(response => {
              this.$modal.msgSuccess("新增成功");
              this.open = false;
              this.getList();
            });
          }
        }
      });
    },
    /** 删除按钮操作 */
    handleDelete(row) {
      const ids = row.id || this.ids;
      this.$modal.confirm('是否确认删除汇总采购入库单编号为"' + ids + '"的数据项？').then(function() {
        return delSumpurinwarehsbill(ids);
      }).then(() => {
        this.getList();
        this.$modal.msgSuccess("删除成功");
      }).catch(() => {});
    },
	/** 汇总采购入库单明细序号 */
    rowOmsSumpurinwarehsbillentryIndex({ row, rowIndex }) {
      row.index = rowIndex + 1;
    },
    /** 汇总采购入库单明细添加按钮操作 */
    handleAddOmsSumpurinwarehsbillentry() {
      let obj = {};
      obj.warehousenumber = "";
      obj.warehousename = "";
      obj.materialnumber = "";
      obj.materialname = "";
      obj.unitnumber = "";
      obj.baseunitnumber = "";
      obj.qty = "";
      obj.baseqty = "";
      obj.price = "";
      obj.taxrate = "";
      obj.taxprice = "";
      obj.amount = "";
      obj.tax = "";
      obj.taxamount = "";
      obj.ispresent = "";
      obj.remark = "";
      this.omsSumpurinwarehsbillentryList.push(obj);
    },
    /** 汇总采购入库单明细删除按钮操作 */
    handleDeleteOmsSumpurinwarehsbillentry() {
      if (this.checkedOmsSumpurinwarehsbillentry.length == 0) {
        this.$modal.msgError("请先选择要删除的汇总采购入库单明细数据");
      } else {
        const omsSumpurinwarehsbillentryList = this.omsSumpurinwarehsbillentryList;
        const checkedOmsSumpurinwarehsbillentry = this.checkedOmsSumpurinwarehsbillentry;
        this.omsSumpurinwarehsbillentryList = omsSumpurinwarehsbillentryList.filter(function(item) {
          return checkedOmsSumpurinwarehsbillentry.indexOf(item.index) == -1
        });
      }
    },
    /** 复选框选中数据 */
    handleOmsSumpurinwarehsbillentrySelectionChange(selection) {
      this.checkedOmsSumpurinwarehsbillentry = selection.map(item => item.index)
    },
    /** 导出按钮操作 */
    handleExport() {
      this.download('settlementCenter/basebill/sumpurinwarehsbill/export', {
        ...this.queryParams
      }, `sumpurinwarehsbill_${new Date().getTime()}.xlsx`)
    },
    /** 单据头序号 */
    rowBillHeadIndex({ row, rowIndex }) {
      row.index = rowIndex + 1;
      let rowName = "",
        findRow = this.ids.indexOf(row.id);
      if (findRow !== -1) {
        rowName = "current-row ";
      }
      row.index = rowIndex + 1;
      return rowName; //也可以再加上其他类名 如果有需求的话
    }
  }
};
</script>
